<?php
//if(!isset($_SESSION[ "JO_account_id" 			])){
	//echo ("login");
//}else{


$loai=isset($_GET['SO_Loai'])?($_GET['SO_Loai']):"";
$CC=isset($_GET['SO_CC'])?($_GET['SO_CC']):"";
$kieu=isset($_GET['SO_kieu'])?($_GET['SO_kieu']):"";


 /*$today=getdate();
 echo "<pre>";
 print_r($today);
 echo $today['year']."-".$today['mon']."-".$today['mday'];
 echo "</pre>";
 exit;*/
     ?>
<link rel="stylesheet"		type="text/css"		href="JO_jquery/themes/smoothness/jquery-ui-1.8.9.custom.css"/>
<script type="text/javascript" src="JO_jquery/ui/jquery-ui-1.8.9.custom.js"></script>
<script >
    
	function searchKeyPress(e)
    {
	
		
        // look for window.event in case event isn't passed in
        if (window.event) { e = window.event; }
        if (e.keyCode == 13)
        {
			
            tuyen_du_lieu('');
            	

        }
    }
function sendtype(p,c){
	
           if(p!='' && c!='')
			location=("../JO/JO_00_integration.php?SO_unit=22_SMS&SO_Loai="+p+"&SO_CC="+c);
			if(p!='' && c=='')
			location=("../JO/JO_00_integration.php?SO_unit=22_SMS&SO_Loai="+p);
    }
function tuyen_du_lieu(p){
	
	$('#loadcontent').html("<div style=\"height: 45px;text-align: center;width:100%;background: url(JO_80_image/jquery.ajaxLoader.gif) center no-repeat\"></div>");
	var loai= $('#choice').val();
	if(loai!='' ){
		if(loai=='day')
		{
			if(sea!='' && sea2!='')
			{
				
				var sea= $('#txtfd').val();
				var sea2=$('#txttd').val();
				var sea3=$('#slpro').val();
				var sea4=$('#txtsearch2').val();
				if(sea3!=''){
				if(p!='')
				var url="JO_71_SO/SO_22_01_SMS.php?SO_loai="+loai+"&SO_sea="+sea+"&SO_sea2="+sea2+"&Page="+p+"&SO_sea3="+sea3+"&SO_sea4="+sea4;
				else
				var url="JO_71_SO/SO_22_01_SMS.php?SO_loai="+loai+"&SO_sea="+sea+"&SO_sea2="+sea2+"&SO_sea3="+sea3+"&SO_sea4="+sea4;}
				else
				{
				$('#loadcontent').html('');
				alert('Phải chọn nhà cung cấp')
				}
			}
			else
			{
				
				$('#loadcontent').html('');
				alert('xin nhập đầy đủ thời gian cần xem')
			}
		}
		else
		{
			
			var sea= $('#txtsearch').val();
			var sea2=$('#slpro').val();
			if(sea2!=''){
			if(p!='')
			var url="JO_71_SO/SO_22_01_SMS.php?SO_loai="+loai+"&SO_sea="+sea+"&Page="+p+"&SO_sea2="+sea2;
			else
			var url="JO_71_SO/SO_22_01_SMS.php?SO_loai="+loai+"&SO_sea="+sea+"&SO_sea2="+sea2;}
			else
			{
				$('#loadcontent').html('');
				alert('Phải chọn nhà cung cấp')
			}
		}
			$('#loadcontent').load(url);
	}
	else
	{
			$('#loadcontent').html('');
			alert('xin mời chọn kiểu xem cần xem')
	}
}
function show()
{
	$('#loadTK').html("<div style=\"height: 45px;text-align: center;width:100%;background: url(JO_80_image/jquery.ajaxLoader.gif) center no-repeat\"></div>");
	var sea= document.getElementById('TKF').value;
	var sea2= document.getElementById('TKT').value;
	var sea3=  document.getElementById('TKS').value;
	var sea4=  document.getElementById('TKCC').value;
	if(sea!='' && sea2!=''){
		if(sea4!=''){
	var url="JO_71_SO/SO_22_02_SMS.php?SO_sea="+sea+"&SO_sea2="+sea2+"&SO_sea3="+sea3+"&SO_sea4="+sea4;	
	//$('#loadTK').html(url);
	$('#loadTK').load(url);}
	else
		{
			$('#loadTK').html('');
			alert('Phải chọn nhà cung cấp')
		}
	}
	else
	{
	$('#loadTK').html('');
		alert('xin nhập đầy đủ thời gian cần xem')
	}
}
/*
function kt()
{
	var chon=document.getElementById('choice').value;
	if(chon=='day')
	{
		document.getElementById('day').innerHTML="Xem từ ngày <input type='text' style='' name='txtfd' id='txtfd' readonly=\"readonly\"/> Đến Ngày <input type='text' style='' name='txttd' id='txttd' readonly=\"readonly\"/> <input type='button' onclick=\"tuyen_du_lieu('')\" value='Xem' style=''/>"
		$("#txtfd").datepicker({ dateFormat: 'yy-mm-dd' }); 
		$("#txttd").datepicker({ dateFormat: 'yy-mm-dd' }); 
	}
	else
	{
		document.getElementById('day').innerHTML="Nội Dung Cần Xem   <input type='text' style='' name='txtsearch' id='txtsearch' onkeypress=\"searchKeyPress(event);\"/> <input type='button' onclick=\"tuyen_du_lieu('')\" value='Xem' style=''/>"
	}
}*/
function chon(c)
{
	
	document.getElementById(c).value='';
}
function bo(c,t)
{
	document.getElementById(c).value=t;
}
function kt()
{
	var chon=$('#choice').val();
	if(chon=='day')
	{
		$('#td001').html("<input type='text' class='input_texti' name='txtsearch2' id='txtsearch2' style='width:144px' />");
		$('#td003').html("<input type='text' class='input_texti' name='txtfd' id='txtfd' value=\'từ ngày\'  onclick=\"chon('txtfd')\" onblur=\"bo('txtfd','từ ngày')\"  readonly=\"readonly\"/>");
		$('#td004').html("<input type='text' class='input_texti' name='txttd' id='txttd' value='Đến ngày'  onclick=\"chon('txttd')\" onblur=\"bo('txttd','đến ngày')\" readonly=\"readonly\"/>");
		$('#td005').html('<input type="button" onclick="tuyen_du_lieu(\'\')" value="Xem" class="input_buttoni" style="float: left;height:24px"/>');
		datime();
		$('#txtsearch2').val('mã người dùng nhập');
		hien_chu();
	}
	else
	{
		
		$('#td001').html("");
		$('#td003').html("");
		$('#td004').html("<input type='text' class='input_texti' name='txtsearch' id='txtsearch' />");
		$('#td005').html('<input type="button" onclick="tuyen_du_lieu(\'\')" value="Xem" class="input_buttoni" style="float: left;height:24px"/>');
		$('#td006').html('');$('#td007').html('');
		datime();
		
	}
}
function datime()
{
		$("#txtfd").datepicker({ dateFormat: 'yy-mm-dd' }); 
		$("#txttd").datepicker({ dateFormat: 'yy-mm-dd' }); 
		$("#txtfd").width(80);
		$("#txttd").width(80);
		$("#slpro").width(80);	
}
function hien_chu()
{
	$('#txtsearch2').click(function(){
		$('#txtsearch2').val('');
		});
	$('#txtsearch2').blur(function(){
		if($('#txtsearch2').val()=='')
		$('#txtsearch2').val('mã người dùng nhập');
		});
	
}
</script>

<div class="JO_left">
  <div class="JO_bar_720">
    <h1> thống kê tin Nhắn</h1>
    
    <!--tong hop-->
    <style>
        .JO_middle td{
			vertical-align:middle;
			}
        </style>
    <table style="width:704px !important">
      <tr>
        <th>Chọn Kiểu Thống kế</th>
        <th>Nhà Cung Cấp </th>
        <?php if(isset($_GET['SO_Loai'])&&$_GET['SO_Loai']=='TH') { 
		 ?>
        <th> Đầu Số </th>
        <th> Từ Ngày</th>
        <th> Đến Ngày </th>
        <th>#</th>
        <?php  }else{?>
        <th  >  </th>
        <th style="text-align:center">Xem Theo</th>
        <th  style="text-align:center" colspan="2"></th>
       
       <?  }?>
      </tr>
      <tr style="vertical-align:middle">
        <td style="width: 140px;text-align:center"><select id="TK" onchange="sendtype(this.value,'')"  style="width:154px;text-align:center">
            <option style="" value="TH"  <?=($loai=="TH")?"selected='selected'":""?> >Thống Kê Tổng Hợp</option>
            <option style="" value="CT" <?=($loai=="CT")?"selected='selected'":""?>>Thống Kê Chi Tiết </option>
          </select></td>
        <?php if(isset($_GET['SO_Loai']) && $_GET['SO_Loai']!='')
					$loai=$_GET['SO_Loai'];
				else
					$loai='TH';
					
	  			if($loai=='TH'){
	   			?>
        <td><select id="TKCC" name="TKCC"  onchange="sendtype('TH',this.value)"  >
            <option style="text-align:center" value=""> tất cả </option>
            <option style="" <?=($CC=="VDC")?"selected='selected'":""?>> VDC </option>
            <option style="" <?=($CC=="INCOM")?"selected='selected'":""?>> INCOM </option>
          </select></td>
        <td><select id="TKS" name="TKS" class="input_selecti">
            <option style="text-align:center" value=""> tất cả </option>
            <option style="">
            <?php
					
						if(!isset($_GET['SO_CC']) || $_GET['SO_CC']=='VDC'){
							echo "8588";}
							else{
							echo '6089';}
					?>
            </option>
            <option style="">
            <?php
					if(!isset($_GET['SO_CC']) || $_GET['SO_CC']=='VDC'){
							echo "8388";}
							else{
							echo '6289';}
					?>
            </option>
            <?php
					if(isset($_GET['SO_CC']))
						if($_GET['SO_CC']=='INCOM')
							echo "<option style=''>6389</option>";
							echo "<option style=''>6589</option>";
							
				 ?>
          </select></td>
        
        <td><input type="text" id="TKF" name="TKF" readonly="readonly" class="input_texti"/></td>
        <td><input type="text" id="TKT" name="TKT" readonly="readonly" class="input_texti"/></td>
        <td ><input type="button" onclick="show();" value="Xem" class="JO_button" /></td>
      </tr>
      <?php
			}else{
		?>
      
        
        <td ><select id="slpro" name="slpro"   class="input_selecti" style="text-align:center">
            <option style="" value=""> tất cả </option>
            <option style="" <?=($CC=="VDC")?"selected='selected'":""?>> VDC </option>
            <option style="" <?=($CC=="INCOM")?"selected='selected'":""?>> INCOM </option>
          </select></td>
          <td></td>
                    <td width="100px" ><select class="input_selecti" onchange="kt()" name="choice" id="choice" style="float: left;text-align:center;margin-right:4px">
            <option style="" value="" >--Chọn kiểu Xem--</option>
            <option style=""  <?=($kieu=="id")?"selected='selected'":""?> value="id" >Xem Theo Mã Người Dùng Nhập</option>
            <option style=""  <?=($kieu=="day")?"selected='selected'":""?> value="day">Xem Theo Ngày</option>
            <option style=""  <?=($kieu=="tel")?"selected='selected'":""?> value="tel">Xem Theo Nhà Mạng</option>
            <option style=""  <?=($kieu=="num")?"selected='selected'":""?> value="num">Xem Theo Đầu Số</option>
          </select></td>
          <td></td>

           
       
      </tr>
      <tr>
       
        
        
        
        <td id="td001" style="vertical-align:middle"></td>
        <td id="td002" style="vertical-align:middle"></td>
        <td id="td003" style="vertical-align:middle"></td>
        <td id="td004" ><input type="text" onkeypress="searchKeyPress(event);" class="input_texti" name="txtsearch" id="txtsearch" style="float: left;" /></td>
        <td id="td005" style="vertical-align:middle"><input type="button" onclick="tuyen_du_lieu('')" value="Xem" class="JO_button" style="height:24px !important"/></td>
      </tr>
      <?php } ?>
    </table>
    <span id="loadTK"> </span> 
    
    <!-- chi tiet--> 
    <span id="loadcontent">
    <div style="height:50px;text-align:center;margin-top:20px;font-size:15px"> </div>
    </span> </div>
</div>
<script>
	$(document).ready(function() { 
        $("#TKF").datepicker({ dateFormat: 'yy-mm-dd' }); 
    }); 
	$(document).ready(function() { 
        $("#TKT").datepicker({ dateFormat: 'yy-mm-dd' }); 
    }); 
</script>
<?
//}
?>
<script>
setwidth();
function setwidth(){
	$("#slpro").width(80);
}
</script>